package org.example.springbootdemo;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.support.MultipartFilter;

@RestController
public class hello {
        @RequestMapping("/sayHi")
        public String springboot(){
            return "hi";
        }

        //只能接受Get请求
        @RequestMapping(value = "/say",method = RequestMethod.GET)
        public String say(){
        return "hi";
    }

        //从类中获取
        @RequestMapping("/person")
        public  String test(Person person){
            return ""+person;
        }

        @RequestMapping("/t1")
        public  String test1(String name){
        return ""+name;
        }

        //重命名
      @RequestMapping("/t2")
        public  String test2(@RequestParam("name")String username) {
          return "" + username;
      }
      //从路径中获取
      @RequestMapping("/t3/{id}/{name}")
        public String test3(@PathVariable("id") Integer id,@PathVariable("name") String name){
            return ""+id+""+name;
      }
      //上传文件
      @RequestMapping("/t4")
        public String test4(MultipartFile file){
            String filename = file.getOriginalFilename();
            return ""+filename;
      }

}
